<?php include('_init_.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/admin-body.css" rel="stylesheet" type="text/css" />
<link href="../css/admin-working.css" rel="stylesheet" type="text/css" />
<link href="../css/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../js/swfobject.js"></script>
<script type="text/javascript" src="../js/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.10.2.datepicker.min.js"></script>
<script type="text/javascript">
// <![CDATA[
$(function(){
	$(".uploadifyupload").each(function(){
		
		var previous_img_id = $(this).attr('name');
		$(this).uploadify({
			'uploader': 'uploadify.swf',
			'cancelImg': 'cancel.png',
			'script': 'uploadify.php',
			'folder': 'files',
			'multi': false,
			'fileExt':'*.jpg;*.jpeg;*.gif;*.png',
				'fileDesc':'Image Files',
			'auto': true,
			'scriptData':{'<?php echo session_name();?>':'<?php echo session_id();?>','name':$(this).attr('name'),'responsetype':'sizeinfo'},
			'displayData': 'speed',
			'onComplete':function(event,queueID,fileObj,response,data){
				var responseObj = eval("("+response+")");
				var fileName = responseObj.name;
				$('#img_'+previous_img_id).attr('src','../img/tmp/' + fileName);
				$('#img_'+previous_img_id).show();
				$('input[name=ajaxf_'+previous_img_id+']').val(fileName);
				
			},
			'onError':function(event,queueId,fileObj,errorObj){
				alert(errorObj);
			}
		});
	});
});
$(function(){
	$('.datepicker').datepicker({ dateFormat: "yy-mm-dd" });
	$('.ck_cat_id').click(function(){
		   $('.ck_cat_id').attr('checked',false);
		   $(this).attr('checked',true);
		      
		});
});

function check_and_post_form()
{

	if ( $('.ck_cat_id:checked').length == 0 ) {
		alert('請選擇類别');
		window.scrollTo(0,0);
		return false;
	}
	var form = document.forms['page_form'];

	if ( form.title.value == '' ) {
		alert('請錄入相簿名稱');
		window.scrollTo(0,0);
		return false;
	}
	if ( form.date.value == '' ) {
		alert('請選擇建立日期');
		window.scrollTo(0,0);
		return false;
	}
	form.submit();
	return false;
}
// ]]>
</script>
<title>班尼頓寫真後台管理</title>
</head>

<body>
<?php include_once('admin-top.php');?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>" name="page_form"> 
<input type="hidden" name="id" value="<?php echo $GLOBALS['PAGE_FORM_DATA']['id'];?>"/>
<input type="hidden" name="act" value="save"/>
<div id="main" class="clearfix"><!-- star #main //-->
  <?php include_once('sub-working.php');?>
  <div id="contactall"><!-- star #main //-->
  <div id="tit" ><!-- star #tit //-->
    <ul>
    <li class="tit-a">管理相簿</li>
    <li class="tit-b"> </li>
    </ul>
  </div><!-- end #tit //-->
  <div id="contactEdit" class="clearfix" ><!-- star #contactEdit //-->
  <ul>
    <li class="ce-1">
     <?php if ($GLOBALS['PAGE_FORM_DATA']['img_path']):?>
    <img  id="img_image" width="300" height="200" src="../img/<?php echo $GLOBALS['GV_IMAGE_PATH'].$GLOBALS['PAGE_FORM_DATA']['img_path'];?>"/>
    <?php else:?>
     <img src="../img/working-none.png" id="img_image" width="300" height="200"/>
    <?php endif;?>
    </li>
    <li class="ce-8">
    <p>作品分類</p>
    <?php foreach($GLOBALS['GV_WORKING_CAT'] as $cat_id=>$cat_name):?>
     <p><input name="cat_id" type="checkbox"  <?php if ($GLOBALS['PAGE_FORM_DATA']['cat_id'] == $cat_id):?>checked="checked"<?php endif;?>  value="<?php echo $cat_id;?>" class="ck_cat_id"/>&nbsp;<?php echo $cat_name;?></p>
    <?php endforeach;?>
    </li>
    <li class="ce-2">相簿名稱：<input name="title" type="text" class="ce-2a" value="<?php echo $GLOBALS['PAGE_FORM_DATA']['title'];?>"/>
    </li>
    <li class="ce-2">建立日期：<input name="date" type="text" class="ce-2a"  value="<?php echo $GLOBALS['PAGE_FORM_DATA']['date'];?>" /></li>
    <li class="ce-2">觀看次數：<?php echo $GLOBALS['PAGE_FORM_DATA']['visit_times'];?></li>
    <li class="ce-3">
    <input id="file_upload1" class="uploadifyupload" type="file" name="image" />
     <input name="ajaxf_image" type="hidden"/>
    </li>
    <li class="ce-4">關鍵字管理（可以選擇五組關鍵字）</li>
    <li class="ce-5">
    <?php foreach($GLOBALS['META_KEY_WORDS']  as $id=>$name):?>
    <p><input  type="checkbox" <?php if(in_array($id, $GLOBALS['PAGE_FORM_DATA']['meta_keyword'])):?>checked="checked"<?php endif;?> value="<?php echo $id;?>" class="checkbox" name="meta_keyword[]"/>&nbsp;&nbsp;<?php echo $name;?></p>
    <?php endforeach;?>
    </li>
    <li class="ce-4">描述內容（最多70個中文字元或是140個英文字元）</li>
    <li class="ce-6">
      <textarea name="meta_description" class="ce-6a"><?php echo $GLOBALS['PAGE_FORM_DATA']['meta_description'];?></textarea>
    </li>
    <li class="ce-7"><a href="#" onclick="return check_and_post_form();">儲存</a></li>
    </ul>

 
  </div><!-- end #contactEdit //-->
  
  </div><!-- end #contactall //-->
</div><!-- end #main //-->
</form>
</body>
</html>